Introduction¶

Kiva.org is an online crowdfunding platform used to extend financial services to financially excluded people around the world. Kiva lenders have provided over $1 billion dollars in loans to over 2 million people. To effectively set investment priorities, assist lenders, and gain insights into their target communities, the organization needs to comprehend the dynamics across the various countries in which it operates.

How Kiva Works:¶

 1.Borrowers submit loan applications through local field partners (local organizations collaborating with Kiva).
 2.Local field partners submit the loan details into the platform.
 3.Loan details undergo verification, editing, and translation into different languages.
 4.Loans are posted on Kiva for lenders to support.
 5.Lenders fund loans in increments of $25 or more through crowdfunding.
 6.Once the target amount is reached, the funds are disbursed via field partners, who distribute them to the borrowers.
 7.Borrowers repay loans based on agreed-upon intervals and schedules.
 8.Lenders utilize repayments to fund new loans, make donations, or withdraw funds.

Task¶

Conduct a comprehensive analysis of Kiva's operations in a country of your choice using a data analysis tool of your preference.

Data dictionary¶

id - Unique ID for loan
funded_amount - The amount disbursed by Kiva to the field agent(USD)
loan_amount - The amount disbursed by the field agent to the borrower(USD)
activity - More granular category
sector - High level category
use - Exact usage of loan amount
country_code - ISO country code of country in which loan was disbursed
country - Full country name of country in which loan was disbursed
region - Full region name within the country
currency - The currency in which the loan was disbursed
partner_id - ID of partner organization
posted_time - The time at which the loan is posted on Kiva by the field agent
disbursed_time - The time at which the loan is disbursed by the field agent to the borrower
funded_time - The time at which the loan posted to Kiva gets funded by lenders completely
term_in_months - The duration for which the loan was disbursed in months
lender_count - The total number of lenders that contributed to this loan
tags - A term assigned to a loan which helps describe it. 
borrower_genders - Comma separated M,F letters, where each instance represents a single male/female in the group
repayment_interval - the periods for which payments are received
date - date the loan is posted on Kiva
In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10, 6)
import seaborn as sns
import plotly.express as px
In [2]:
kiva = pd.read_csv("kiva_loans.csv")
mpi_region = pd.read_csv("kiva_mpi_region_locations.csv")
loan_themeid = pd.read_csv("loan_theme_ids.csv")
loan_themes_region = pd.read_csv("loan_themes_by_region.csv")

Data Cleaning¶

In [3]:
#check for missing values from the dataframes.
kiva.isna()
mpi_region.isna()
loan_themeid.isna()
loan_themes_region.isna()
Out[3]:
Partner ID Field Partner Name sector Loan Theme ID Loan Theme Type country forkiva region geocode_old ISO ... amount LocationName geocode names geo lat lon mpi_region mpi_geo rural_pct
0 False False False False False False False False False False ... False False False False False False False False False False
1 False False False False False False False False True False ... False False False False False False False False False False
2 False False False False False False False False True False ... False False False False False False False False False False
3 False False False False False False False False False False ... False False False False False False False False False False
4 False False False False False False False False False False ... False False False False False False False False False False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
15731 False False False False False False False False True False ... False False False False False False False False True True
15732 False False False False False False False False False False ... False False False False False False False False False True
15733 False False False False False False False False False False ... False False False False False False False False False True
15734 False False False False False False False False True False ... False False False False False False False False True True
15735 False False False False False False False False True False ... False False False False False False False False False True

15736 rows × 21 columns

In [4]:
kiva.isna()
Out[4]:
id funded_amount loan_amount activity sector use country_code country region currency partner_id posted_time disbursed_time funded_time term_in_months lender_count tags borrower_genders repayment_interval date
0 False False False False False False False False False False False False False False False False True False False False
1 False False False False False False False False False False False False False False False False True False False False
2 False False False False False False False False False False False False False False False False False False False False
3 False False False False False False False False False False False False False False False False True False False False
4 False False False False False False False False False False False False False False False False True False False False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
671200 False False False False False False False False False False False False False True False False True False False False
671201 False False False False False False False False True False False False False False False False True False False False
671202 False False False False False True False False True False False False False True False False True True False False
671203 False False False False False False False False True False False False False True False False True False False False
671204 False False False False False False False False True False False False False True False False True False False False

671205 rows × 20 columns

In [5]:
kiva.tail(10)
Out[5]:
id funded_amount loan_amount activity sector use country_code country region currency partner_id posted_time disbursed_time funded_time term_in_months lender_count tags borrower_genders repayment_interval date
671195 1340329 0.0 50.0 Livestock Agriculture Edited loan use in english. GH Ghana Dansoman GHS 231.0 2017-07-25 22:40:59+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female, female monthly 2017-07-25
671196 1340325 0.0 250.0 Livestock Agriculture Reviewed loan use in english. GH Ghana Dansoman GHS 231.0 2017-07-25 21:36:20+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-25
671197 1340330 0.0 25.0 Livestock Agriculture Pretend the issue with loan got addressed by K... KE Kenya NaN KES 138.0 2017-07-25 22:55:42+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-25
671198 1340331 0.0 75.0 Livestock Agriculture Pretend the issue with spanish loan was addres... MX Mexico Iztacalco MXN 294.0 2017-07-25 23:13:50+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-25
671199 1340318 0.0 25.0 Livestock Agriculture [True, u'para compara: cemento, arenya y ladri... PY Paraguay Concepción USD 58.0 2017-07-25 06:45:02+00:00 2017-07-24 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-25
671200 1340323 0.0 25.0 Livestock Agriculture [True, u'para compara: cemento, arenya y ladri... PY Paraguay Concepción USD 58.0 2017-07-25 16:55:34+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-25
671201 1340316 25.0 25.0 Livestock Agriculture [True, u'to start a turducken farm.'] - this l... KE Kenya NaN KES 138.0 2017-07-25 06:14:08+00:00 2017-07-24 07:00:00+00:00 2017-07-26 02:09:43+00:00 13.0 1 NaN female monthly 2017-07-25
671202 1340334 0.0 25.0 Games Entertainment NaN KE Kenya NaN KES 138.0 2017-07-26 00:02:07+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN NaN monthly 2017-07-26
671203 1340338 0.0 25.0 Livestock Agriculture [True, u'to start a turducken farm.'] - this l... KE Kenya NaN KES 138.0 2017-07-26 06:12:55+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-26
671204 1340339 0.0 25.0 Livestock Agriculture [True, u'to start a turducken farm.'] - this l... KE Kenya NaN KES 138.0 2017-07-26 06:31:46+00:00 2017-07-25 07:00:00+00:00 NaN 13.0 0 NaN female monthly 2017-07-26
In [6]:
mpi_region.isna().tail(10)
Out[6]:
LocationName ISO country region world_region MPI geo lat lon
2762 True True True True True True False True True
2763 True True True True True True False True True
2764 True True True True True True False True True
2765 True True True True True True False True True
2766 True True True True True True False True True
2767 True True True True True True False True True
2768 True True True True True True False True True
2769 True True True True True True False True True
2770 True True True True True True False True True
2771 True True True True True True False True True
In [7]:
cleaned_data = [kiva,mpi_region,loan_themeid,loan_themes_region]
for x in cleaned_data:
    missing_values = x.dropna(inplace = True)
In [8]:
kiva.tail(10)
Out[8]:
id funded_amount loan_amount activity sector use country_code country region currency partner_id posted_time disbursed_time funded_time term_in_months lender_count tags borrower_genders repayment_interval date
671006 1338429 400.0 400.0 Fruits & Vegetables Food to buy more vegetables to sell, in order to ha... SV El Salvador San Miguel USD 199.0 2017-07-12 15:48:37+00:00 2017-07-06 07:00:00+00:00 2017-07-14 15:47:04+00:00 14.0 9 volunteer_pick, #Single Parent, #Parent, #Repe... female monthly 2017-07-12
671084 1338347 300.0 300.0 Natural Medicines Health to buy more nutritional supplements to keep se... SV El Salvador San Miguel USD 199.0 2017-07-12 14:25:23+00:00 2017-06-30 07:00:00+00:00 2017-07-15 14:21:03+00:00 9.0 7 #Health and Sanitation male irregular 2017-07-12
671093 1338648 1300.0 1300.0 Retail Retail to buy perfumes, creams, lotions, etc. EC Ecuador Portoviejo USD 137.0 2017-07-12 22:53:22+00:00 2017-06-30 07:00:00+00:00 2017-07-15 15:50:13+00:00 7.0 4 #Parent, #Woman Owned Biz, #Repeat Borrower female monthly 2017-07-12
671097 1338653 500.0 500.0 Crafts Arts to buy thread to make hammocks. SV El Salvador Gotera USD 199.0 2017-07-12 23:16:52+00:00 2017-06-12 07:00:00+00:00 2017-07-15 23:29:36+00:00 12.0 9 #Fabrics, user_favorite, user_favorite female bullet 2017-07-12
671105 1338792 2600.0 2600.0 Food Production/Sales Food to buy supplies for making cheese buns [chipas... PY Paraguay Paraguari PYG 58.0 2017-07-13 03:06:02+00:00 2017-06-13 07:00:00+00:00 2017-07-15 21:41:13+00:00 6.0 13 #Woman Owned Biz female, female, female, female, female, female... irregular 2017-07-13
671107 1338832 350.0 350.0 Personal Medical Expenses Health to pay for her husband's operation and hospita... TJ Tajikistan Isfara TJS 63.0 2017-07-13 04:38:24+00:00 2017-07-12 07:00:00+00:00 2017-07-14 16:36:03+00:00 14.0 9 volunteer_like, #Health and Sanitation female monthly 2017-07-13
671110 1338784 2700.0 2700.0 Perfumes Retail to buy a range of clothing and perfumes to sell. PY Paraguay Ita PYG 58.0 2017-07-13 02:54:56+00:00 2017-06-13 07:00:00+00:00 2017-07-15 20:23:53+00:00 5.0 21 #Woman Owned Biz female, female, female, female, female, female... irregular 2017-07-13
671133 1338878 475.0 475.0 Higher education costs Education to pay her son's tuition. TJ Tajikistan Dushanbe TJS 63.0 2017-07-13 06:38:39+00:00 2017-07-11 07:00:00+00:00 2017-07-16 04:29:11+00:00 14.0 12 #Schooling, #Parent female monthly 2017-07-13
671134 1338682 3525.0 3525.0 Grocery Store Food to buy drinks, baked goods, greens, meat, vege... PY Paraguay Ciudad del Este PYG 58.0 2017-07-13 00:31:11+00:00 2017-06-13 07:00:00+00:00 2017-07-15 17:44:19+00:00 5.0 16 #Woman Owned Biz female, female, female, female, female, female... irregular 2017-07-13
671141 1339713 175.0 175.0 Sewing Services to purchase of a digital sewing machine for em... TJ Tajikistan Hamadoni TJS 63.0 2017-07-14 05:27:46+00:00 2017-07-05 07:00:00+00:00 2017-07-14 19:10:26+00:00 14.0 5 #Biz Durable Asset, #Fabrics female monthly 2017-07-14

Data Exploration¶

Part 1: Questions for the whole of kiva dataset¶

1.Which region had the highest loan amount?¶

In [9]:
region = kiva.groupby("region")["loan_amount"].sum().sort_values(ascending = False).head(10)

fig = px.bar(region,y="loan_amount",color_discrete_sequence = ["blue"])
fig.update_layout(
    title = "Loan Amount by Region",
    title_x = 0.5,)

fig.show()

Goma,North Kivu Province was the region with the highest loan amount.

2.What is the distribution of loans between male and female recipients, and what insights can be drawn from this?¶

In [10]:
kiva[["borrower_genders"]]
Out[10]:
borrower_genders
2 female
6 female
7 female
8 female
12 female
... ...
671107 female
671110 female, female, female, female, female, female...
671133 female
671134 female, female, female, female, female, female...
671141 female

423081 rows × 1 columns

In [11]:
kiva['borrower_genders'] = kiva['borrower_genders'].str.split(', ')
kiva = kiva.explode('borrower_genders', ignore_index=True)
kiva[["borrower_genders"]]
Out[11]:
borrower_genders
0 female
1 female
2 female
3 female
4 female
... ...
879358 female
879359 female
879360 female
879361 female
879362 female

879363 rows × 1 columns

In [12]:
fig = px.pie(kiva, values ="loan_amount", names= "borrower_genders")
fig.update_layout(
    title = "Loan Amount by Gender",
    title_x = 0.5,)

fig.show()
In [13]:
sns.countplot(data = kiva, x = "borrower_genders")

plt.title("Loan Amount by Gender",fontsize = 16, color = "blue")
plt.show()
In [14]:
fig = px.histogram(data_frame = kiva,x = "lender_count",range_x=[0,30],color = "borrower_genders",color_discrete_sequence=["orange","blue"],template = "simple_white")
fig.update_layout(
    title = "Lender Count by Gender",
    title_x = 0.5,)

fig.show()

Females make up approximately 80% of all borrowers, while males account for around 20%.Female borrowers are more than the male borrowers

3. Explore the relationship between lender counts and funded amounts providing explanations for the results.¶

In [15]:
fig = px.scatter(data_frame = kiva, x ="funded_amount",y = "lender_count",size_max=100)

fig.update_layout(
    title = "Lender Count vs Funded Amount",
    title_x = 0.5,)
fig.show()

There is a positive relationship between the lender count and the funded amount. As the number of people borrowing loans increases, the funded amount also increases. It appears that a higher lender count is associated with a higher distribution of funded amounts. In other words, when more people participate as lenders, more loans tend to be funded.

Part 2:Questions for the subset¶

In [16]:
#subset the data
nigeria = kiva[kiva["country"] == "Nigeria"].reset_index(drop = True)
nigeria
Out[16]:
id funded_amount loan_amount activity sector use country_code country region currency partner_id posted_time disbursed_time funded_time term_in_months lender_count tags borrower_genders repayment_interval date
0 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN 365.0 2014-03-27 08:59:23+00:00 2014-06-24 07:00:00+00:00 2014-04-04 15:49:54+00:00 11.0 50 #Biz Durable Asset, #Supporting Family, #Job C... female bullet 2014-03-27
1 689878 1475.0 1475.0 Agriculture Agriculture to help Ebele complete the total cost of build... NG Nigeria Elele NGN 365.0 2014-03-27 10:04:05+00:00 2014-06-24 07:00:00+00:00 2014-04-04 17:48:30+00:00 11.0 53 user_favorite, user_favorite, #Biz Durable Ass... female bullet 2014-03-27
2 694582 1125.0 1125.0 Agriculture Agriculture to purchase palm bunches, process and store ed... NG Nigeria Umutanzi NGN 365.0 2014-04-07 15:24:11+00:00 2014-03-31 07:00:00+00:00 2014-04-11 19:47:40+00:00 9.0 44 user_favorite male bullet 2014-04-07
3 694582 1125.0 1125.0 Agriculture Agriculture to purchase palm bunches, process and store ed... NG Nigeria Umutanzi NGN 365.0 2014-04-07 15:24:11+00:00 2014-03-31 07:00:00+00:00 2014-04-11 19:47:40+00:00 9.0 44 user_favorite female bullet 2014-04-07
4 694582 1125.0 1125.0 Agriculture Agriculture to purchase palm bunches, process and store ed... NG Nigeria Umutanzi NGN 365.0 2014-04-07 15:24:11+00:00 2014-03-31 07:00:00+00:00 2014-04-11 19:47:40+00:00 9.0 44 user_favorite female bullet 2014-04-07
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
6123 1332090 750.0 750.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN 288.0 2017-07-03 11:40:46+00:00 2017-07-10 07:00:00+00:00 2017-07-12 03:04:41+00:00 19.0 21 #Vegan, #Parent, #Schooling female bullet 2017-07-03
6124 1332983 50.0 50.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN 288.0 2017-07-04 11:44:00+00:00 2017-07-10 07:00:00+00:00 2017-07-12 12:15:55+00:00 19.0 2 #Vegan, #Schooling male bullet 2017-07-04
6125 1333129 75.0 75.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN 288.0 2017-07-04 14:33:12+00:00 2017-07-10 07:00:00+00:00 2017-07-12 20:08:10+00:00 19.0 3 volunteer_like, #Vegan male bullet 2017-07-04
6126 1333135 75.0 75.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN 288.0 2017-07-04 14:41:13+00:00 2017-07-13 07:00:00+00:00 2017-07-13 03:11:46+00:00 19.0 3 #Vegan male bullet 2017-07-04
6127 1334000 125.0 125.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN 288.0 2017-07-05 12:12:32+00:00 2017-07-12 07:00:00+00:00 2017-07-14 19:59:04+00:00 19.0 5 #Vegan, #Parent, #Schooling male bullet 2017-07-05

6128 rows × 20 columns

1.Calculate the number of loans per sector¶

In [17]:
loans_per_sector =nigeria.groupby("sector")["loan_amount"].sum().sort_values(ascending = False).reset_index()
fig = px.bar(loans_per_sector, x = "sector",y = "loan_amount",color = "sector")
fig.update_layout(
           title= "Total Loan Amount by Sector",
           title_x =0.5)
fig.show()
#total loan amount per sector
In [18]:
sector_loans =nigeria.groupby("sector")["loan_amount"].count().sort_values(ascending = False).reset_index()
fig = px.bar(sector_loans[::-1], x = "loan_amount",y = "sector",color = "sector")
fig.update_layout(
           title= "Loan Amount by Sector",
           title_x =0.5)
fig.show()

2.Determine the gender lead in the different sectors.¶

In [19]:
sector_gender_lead = nigeria.groupby(["sector","borrower_genders"])["loan_amount"].sum().sort_values(ascending = False).reset_index()

fig = px.bar(data_frame = sector_gender_lead,x ="sector",y="loan_amount",color = "borrower_genders", barmode = "group")
fig.update_layout(
           title= "Gender Lead by Sector",
           title_x =0.5)

fig.show()

There is a noticeable divergence in borrowing patterns between males and females in Nigeria.The male borrowers tend to favor the agricultural sector since they frequently allocate borrowed money toward activities related to agriculture. Females exhibit a stronger presence in the food sector.There is a gender-based discrepancy in investment choices, with males showing a pronounced interest in agriculture, while females focus their borrowing on food-related activities.

3.Visualize the number of loans per month¶

In [20]:
nigeria.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 6128 entries, 0 to 6127
Data columns (total 20 columns):
 #   Column              Non-Null Count  Dtype  
---  ------              --------------  -----  
 0   id                  6128 non-null   int64  
 1   funded_amount       6128 non-null   float64
 2   loan_amount         6128 non-null   float64
 3   activity            6128 non-null   object 
 4   sector              6128 non-null   object 
 5   use                 6128 non-null   object 
 6   country_code        6128 non-null   object 
 7   country             6128 non-null   object 
 8   region              6128 non-null   object 
 9   currency            6128 non-null   object 
 10  partner_id          6128 non-null   float64
 11  posted_time         6128 non-null   object 
 12  disbursed_time      6128 non-null   object 
 13  funded_time         6128 non-null   object 
 14  term_in_months      6128 non-null   float64
 15  lender_count        6128 non-null   int64  
 16  tags                6128 non-null   object 
 17  borrower_genders    6128 non-null   object 
 18  repayment_interval  6128 non-null   object 
 19  date                6128 non-null   object 
dtypes: float64(4), int64(2), object(14)
memory usage: 957.6+ KB
In [21]:
nigeria["date"] = nigeria["date"].astype("datetime64")
nigeria["month"] = nigeria["date"].dt.month_name()
nigeria.head()
Out[21]:
id funded_amount loan_amount activity sector use country_code country region currency ... posted_time disbursed_time funded_time term_in_months lender_count tags borrower_genders repayment_interval date month
0 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN ... 2014-03-27 08:59:23+00:00 2014-06-24 07:00:00+00:00 2014-04-04 15:49:54+00:00 11.0 50 #Biz Durable Asset, #Supporting Family, #Job C... female bullet 2014-03-27 March
1 689878 1475.0 1475.0 Agriculture Agriculture to help Ebele complete the total cost of build... NG Nigeria Elele NGN ... 2014-03-27 10:04:05+00:00 2014-06-24 07:00:00+00:00 2014-04-04 17:48:30+00:00 11.0 53 user_favorite, user_favorite, #Biz Durable Ass... female bullet 2014-03-27 March
2 694582 1125.0 1125.0 Agriculture Agriculture to purchase palm bunches, process and store ed... NG Nigeria Umutanzi NGN ... 2014-04-07 15:24:11+00:00 2014-03-31 07:00:00+00:00 2014-04-11 19:47:40+00:00 9.0 44 user_favorite male bullet 2014-04-07 April
3 694582 1125.0 1125.0 Agriculture Agriculture to purchase palm bunches, process and store ed... NG Nigeria Umutanzi NGN ... 2014-04-07 15:24:11+00:00 2014-03-31 07:00:00+00:00 2014-04-11 19:47:40+00:00 9.0 44 user_favorite female bullet 2014-04-07 April
4 694582 1125.0 1125.0 Agriculture Agriculture to purchase palm bunches, process and store ed... NG Nigeria Umutanzi NGN ... 2014-04-07 15:24:11+00:00 2014-03-31 07:00:00+00:00 2014-04-11 19:47:40+00:00 9.0 44 user_favorite female bullet 2014-04-07 April

5 rows × 21 columns

In [22]:
nigeria_sorted = nigeria.sort_values(by="loan_amount",ascending = False)
with plt.style.context("ggplot"):
    plt.title("Loan Amount by Month",fontsize = 16, color = "blue")
    plt.ticklabel_format(style = "plain")
    plt.xlabel("month")
    plt.ylabel("loan_amount")
    plt.xticks(rotation = 75)
    plt.bar(nigeria_sorted["month"], nigeria_sorted["loan_amount"],color = "green")

plt.show()

The month of August is the predominant month for borrowing in Nigeria.

4. Visualize the top ten regions marked by loan amount¶

In [23]:
top_ten_regions = nigeria.groupby("region")["loan_amount"].sum().sort_values(ascending = False).reset_index().head(10)
top_ten_regions
Out[23]:
region loan_amount
0 Kaduna 1267000.0
1 Uruagu 79475.0
2 Nnewi 65025.0
3 Ozubulu 40125.0
4 Obiofia 38975.0
5 Okwu-Ubaha Okporo 30875.0
6 Akaboezem 30725.0
7 Umutanzi 26650.0
8 Nnewichi 25575.0
9 Abobur 22800.0
In [24]:
fig = px.bar( top_ten_regions,x = "region",y = "loan_amount",color = "region")
fig.update_layout(
           title= "Top Ten Regions by Loan Amount",
           title_x =0.5)

fig.show()

5.Showcase the funded amount distribution by region¶

In [25]:
funded_regions = nigeria.groupby("region")["funded_amount"].sum().sort_values(ascending = False).reset_index()
funded_regions
Out[25]:
region funded_amount
0 Kaduna 1267000.0
1 Uruagu 79475.0
2 Nnewi 65025.0
3 Ozubulu 40125.0
4 Obiofia 38975.0
5 Okwu-Ubaha Okporo 30875.0
6 Akaboezem 30725.0
7 Umutanzi 26650.0
8 Nnewichi 25575.0
9 Abobur 22800.0
10 Umudim 19625.0
11 OBA 14575.0
12 Ubaha Okporo 12200.0
13 Nnobi 12000.0
14 Otolo Nnewi 9500.0
15 Enugu-ukwe 8550.0
16 Amichi 3000.0
17 Ojoto 2100.0
18 Elele 1475.0
19 Akatta Oru East 1450.0
20 ORAIFITE 500.0
In [26]:
plt.figure(figsize = (20, 10))

plt.subplot(1, 2, 1)
plt.title("Funded Amount by Region",fontsize = 16, color = "blue")
plt.ticklabel_format(style = "plain")
plt.xlabel("region")
plt.ylabel("funded_amount")
plt.xticks(rotation = 90)
plt.plot(funded_regions["region"],funded_regions["funded_amount"],"b--o")
plt.grid(True)

plt.subplot(1, 2, 2)
plt.title("Funded Amount by Region",fontsize = 16, color = "blue")
plt.ticklabel_format(style = "plain")
plt.xlabel("region")
plt.ylabel("funded_amount")
plt.xticks(rotation = 90)
plt.bar(funded_regions["region"],funded_regions["funded_amount"])


plt.show()

Showcase the funded amount distribution by region(ii)¶

In [27]:
kiva.columns
Out[27]:
Index(['id', 'funded_amount', 'loan_amount', 'activity', 'sector', 'use',
       'country_code', 'country', 'region', 'currency', 'partner_id',
       'posted_time', 'disbursed_time', 'funded_time', 'term_in_months',
       'lender_count', 'tags', 'borrower_genders', 'repayment_interval',
       'date'],
      dtype='object')
In [28]:
mpi_region.columns
Out[28]:
Index(['LocationName', 'ISO', 'country', 'region', 'world_region', 'MPI',
       'geo', 'lat', 'lon'],
      dtype='object')
In [29]:
new_kiva = pd.merge(kiva,mpi_region, on = "country")
nigeria1 = new_kiva[new_kiva["country"] == "Nigeria"].reset_index(drop = True)
nigeria1
Out[29]:
id funded_amount loan_amount activity sector use country_code country region_x currency ... repayment_interval date LocationName ISO region_y world_region MPI geo lat lon
0 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN ... bullet 2014-03-27 Sokoto, Nigeria NGA Sokoto Sub-Saharan Africa 0.548 (13.0058731, 5.2475518) 13.005873 5.247552
1 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN ... bullet 2014-03-27 Zamfara, Nigeria NGA Zamfara Sub-Saharan Africa 0.605 (6.907529, 3.5812692) 6.907529 3.581269
2 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN ... bullet 2014-03-27 Katsina, Nigeria NGA Katsina Sub-Saharan Africa 0.520 (12.5139317, 7.6114217) 12.513932 7.611422
3 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN ... bullet 2014-03-27 Jigawa, Nigeria NGA Jigawa Sub-Saharan Africa 0.552 (12.4460001, 9.7232673) 12.446000 9.723267
4 689794 1450.0 1450.0 Agriculture Agriculture to help Uche purchase a modern palm oil proces... NG Nigeria Amichi NGN ... bullet 2014-03-27 Yobe, Nigeria NGA Yobe Sub-Saharan Africa 0.635 (12.1871412, 11.7068294) 12.187141 11.706829
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
214475 1334000 125.0 125.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN ... bullet 2017-07-05 Rivers, Nigeria NGA Rivers Sub-Saharan Africa 0.088 (4.8580767, 6.920913499999999) 4.858077 6.920913
214476 1334000 125.0 125.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN ... bullet 2017-07-05 Bayelsa, Nigeria NGA Bayelsa Sub-Saharan Africa 0.120 (4.867776699999999, 5.898713900000001) 4.867777 5.898714
214477 1334000 125.0 125.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN ... bullet 2017-07-05 Delta, Nigeria NGA Delta Sub-Saharan Africa 0.107 (5.5324624, 5.898713900000001) 5.532462 5.898714
214478 1334000 125.0 125.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN ... bullet 2017-07-05 Lagos, Nigeria NGA Lagos Sub-Saharan Africa 0.035 (6.5243793, 3.3792057) 6.524379 3.379206
214479 1334000 125.0 125.0 Farming Agriculture to purchase improved farm inputs that will inc... NG Nigeria Kaduna NGN ... bullet 2017-07-05 Ogun, Nigeria NGA Ogun Sub-Saharan Africa 0.112 (12.8463561, 23.0011989) 12.846356 23.001199

214480 rows × 28 columns

In [30]:
px.set_mapbox_access_token("pk.eyJ1IjoiZXJuZXN0NDA0IiwiYSI6ImNsaHZubXlqbTBhODkzZW1kYzB0YWkxdDkifQ.weQF41nLDzr8jHi9tIHwPQ")
In [31]:
fig = px.scatter_mapbox(nigeria1, lat = "lat", lon = "lon", color = "region_x",size = "funded_amount")
fig.update_layout(
           title= "Funded Amount by Region",
           title_x =0.5)
fig.show()

6. Determine the primary reason for both the male and female borrowers¶

In [32]:
female_borrowers = nigeria[nigeria['borrower_genders'] == 'female']
male_borrowers = nigeria[nigeria['borrower_genders'] == 'male']
In [33]:
female_loan_reasons = female_borrowers['use'].value_counts()
male_loan_reasons = male_borrowers['use'].value_counts()

plt.barh(female_loan_reasons.head(10).index, female_loan_reasons.head(10), color='green', label='Female Borrowers')
plt.barh(male_loan_reasons.head(10).index, male_loan_reasons.head(10), color='blue', label='Male Borrowers')
plt.xlabel('Frequency')
plt.ylabel('Loan Reasons')
plt.legend()
plt.title('Top 10 Loan Reasons by Gender')

plt.show()

Under the agricultural sector,males used the money they borrowed to purchase farm inputs that will increase farm yields,access high quality fertilizer while the females used the money to process and store plam oil products.

7. Examine repayment intervals across different regions.¶

In [34]:
descending = nigeria.groupby("region")["loan_amount"].sum().sort_values(ascending = False).index
descending
Out[34]:
Index(['Kaduna', 'Uruagu', 'Nnewi', 'Ozubulu', 'Obiofia', 'Okwu-Ubaha Okporo',
       'Akaboezem', 'Umutanzi', 'Nnewichi', 'Abobur', 'Umudim', 'OBA',
       'Ubaha Okporo', 'Nnobi', 'Otolo Nnewi', 'Enugu-ukwe', 'Amichi', 'Ojoto',
       'Elele', 'Akatta Oru East', 'ORAIFITE'],
      dtype='object', name='region')
In [35]:
nigeria[["repayment_interval","region"]]
Out[35]:
repayment_interval region
0 bullet Amichi
1 bullet Elele
2 bullet Umutanzi
3 bullet Umutanzi
4 bullet Umutanzi
... ... ...
6123 bullet Kaduna
6124 bullet Kaduna
6125 bullet Kaduna
6126 bullet Kaduna
6127 bullet Kaduna

6128 rows × 2 columns

In [36]:
repayment_interval = nigeria.groupby(["region","repayment_interval"])["loan_amount"].sum().sort_values(ascending = False).reset_index()
fig = px.bar(data_frame = repayment_interval,x ="region",y="loan_amount",color = "repayment_interval")
fig.update_layout(
    title="Repayment Interval by Region",
    title_x=0.5,
)

fig.show()

Repayment interval in most regions is bullet while kaduna has both the bullet and irregular interval of loan repayment method.

In [37]:
fig = px.bar(nigeria, x="region", y="loan_amount",animation_frame ="repayment_interval",animation_group="region",color = "repayment_interval",range_y=[0,3600])
fig.update_layout(
    title="Repayment Interval",
    title_x=0.5,
)

fig.show()

Summary¶

Kiva Crowdfunding Analysis Overview:

Loan Distribution: Kiva operates across various regions, and the analysis explores the distribution of loans overally and specifically in Nigeria.

Top Recipient: Goma, North Kivu Province, received the highest loan amount.From the subset,Kaduna receives the highest loans in Nigeria.

Gender Analysis: Overall, females are the predominant borrowers, making up approximately 83.2% of the borrowers while males make 16.8% of borrowers.

Relationship: A positive correlation exists between the lender count and the funded amount. As more individuals participate as lenders, the total funded amount increases. However, it's worth noting that higher funded amounts are less common.

Sector and Activity Insights:

Sectors: The Agriculture sector is the most frequently chosen sector for loans, followed by the Food sector.

Interval Payments: Various payment intervals are observed, including monthly, irregular, bullet, and weekly. Bullet payments are the most frequent in Nigeria, while irregular payments are less common.

Top Loan Activities: Agriculture and personal use are the top two activities that receive the highest funding, while construction activities receive the least.

Loan Timing: The month of August sees the highest loan disbursements, while January has the lowest activity.

In [ ]: